package com.csdj.t301.cloud.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * author:cloud
 * date:2021/3/3 0003
 **/
@Aspect
@Component
public class AopLogging {

    @Pointcut("execution(* com.csdj..test(String,String))")
    public void cutpoint(){}

    @Before("cutpoint()")
    public void printParam(JoinPoint jp){
        System.out.println("调用对象："+jp.getTarget()+" 方法:"+jp.getSignature().getName());
    }

    @Around("cutpoint()")
    public void around(ProceedingJoinPoint pjp){
        System.out.println("开始执行");
        long start = System.currentTimeMillis();
        try {
//            pjp.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        long time = System.currentTimeMillis()-start;
        System.out.println("执行结束 时间："+time);
    }
}
